<?php
namespace app\index\controller;

class Zhibo extends Base
{
    public function index(){
        $title = input('title');
        $currenttime = time() - 60*60*2;
        $where[] = ['ld.ts' , '>' ,$currenttime];
        if(!empty($title)){
            $title = urldecode($title);
            $where[] = ['ld.cup_title', 'like' , '%'.$title.'%'];
        }
        $doclist = db('livedata',[] , false)->alias('ld')->field('ld.*,t.logo_b64 t_l,t1.logo_b64 t1_l')->where($where)
            ->join('team t','t.team_name_cn = ld.home' , 'LEFT')
            ->join('team t1','t1.team_name_cn = ld.away' , 'LEFT')
            ->order('ld.ts asc')
            ->select();
        return $this->fetchHtml('index' , [
            'web_title'=> '',
            'web_kw'   => '',
            'web_desc' => '',
            'doclist' => $doclist
        ]);
    }


    public function info($id){
        $doc = db('livedata',[] , false)->alias('ld')->field('ld.*,t.logo_b64 t_l,t1.logo_b64 t1_l')->where(['ld.id' => $id])->join('team t','t.team_name_cn = ld.home' , 'LEFT')
            ->join('team t1','t1.team_name_cn = ld.away' , 'LEFT')
            ->find();
        return $this->fetchHtml('info' , [
            'web_title'=> $doc['cup_title'],
            'web_kw'   => $doc['cup_title'],
            'web_desc' => $doc['cup_title'],
            'doc' => $doc
        ]);
    }
}